<?php
/**
 * Created by PhpStorm.
 * User: cy
 * Date: 2018/4/9
 * Time: 16:12
 */
namespace app\modules\content\controllers;

use app\libs\ApiControl;
use app\libs\AppControl;
use app\libs\Method;
use app\modules\basic\models\Block;
use app\modules\cn\models\Content;
use app\modules\cn\models\ExamResource;
use app\modules\cn\models\ResourcesPhone;
use app\modules\cn\models\Teachers;
use app\modules\cn\models\User;
use app\modules\content\models\AdsBanner;
use app\modules\content\models\OfferImage;
use app\modules\content\models\TeacherColumn;
use Yii;
use yii\data\Pagination;
use yii\web\UploadedFile;

class ReservePhoneController extends ApiControl {
    public $enableCsrfValidation = false;

    /**
     * 列表
     * @Author: Ferre
     * @create: 2021/3/9 15:03
     * @return string
     */
    public function actionIndex()
    {
        $where      = "1=1";
        $id         = Yii::$app->request->get('id');
        if (!empty($id)) $where .= " and id=$id";
        $count      = ResourcesPhone::find()->select("id")->where($where)->count();
        $page       = new Pagination(['totalCount'=>$count,'pageSize'=>20]);
        $open_class = ResourcesPhone::find()->asArray()->where($where)->offset($page->offset)->orderBy('id desc')->limit($page->limit)->all();
        return $this->render('index',['content'=>$open_class,'page'=>$page]);
    }

    /**
     * 处理电话
     * @Author: Ferre
     * @create: 2021/3/15 16:47
     */
    public function actionHandlePhone()
    {
        $id = Yii::$app->request->get('id');
        ResourcesPhone::updateAll(['status' => 1], ['id' => $id]);
        $this->redirect(['index']);
    }

}
